package com.si3.controlador;
import java.util.List;

import com.si3.modelo.Login;
import com.si3.modelo.Profesor;
import com.si3.modelo.Propuesta;
import com.si3.modelo.Solicitud;
import com.si3.modelo.Usuario;
import com.si3.servicio.PropuestasService;
import com.si3.servicio.SolicitudesService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;



public class RechazarSolicitudController extends AbstractController
{
   private SolicitudesService solicitudesService;
   
   public RechazarSolicitudController()
   {
   }

   public void setSolicitudesService(SolicitudesService service)
   {
       this.solicitudesService = service;
   }

   public SolicitudesService getSolicitudesService()
   {
       return solicitudesService;
   }
   
   
   
   protected ModelAndView handleRequestInternal(
             HttpServletRequest request,
             HttpServletResponse response) throws Exception
  {
            
      ModelAndView mv=new ModelAndView("showMessage");
  	  String codigoSolicitud = request.getParameter("codigo"); 
           
     //get login token
      Login login = (Login) request.getSession().getAttribute("login");
      if (login.getUserType() == Usuario.TipoUsuario.ADMIN)
      {
      	  solicitudesService.rechazarSolicitud(Integer.parseInt(codigoSolicitud));      	  
          mv.addObject("message", "La solicitud se ha rechazado correctamente.");
          mv.addObject("tipo", "administrador");
      }
      return mv;
   }
}

 
   